home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 6 / MacMania 6.toast / / Tools&Utilities / EnterAct Stuff / Indent project / Indent Source / parse.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  18.3 KB  |  581 lines  |  [TEXT/MPS ]

  1. /* Copyright (c) 1994, Joseph Arceneaux.  All rights reserved
  2.  
  3.    Copyright (c) 1985 Sun Microsystems, Inc. Copyright (c) 1980 The Regents
  4.    of the University of California. Copyright (c) 1976 Board of Trustees of
  5.    the University of Illinois. All rights reserved.
  6.  
  7.    Redistribution and use in source and binary forms are permitted provided
  8.    that the above copyright notice and this paragraph are duplicated in all
  9.    such forms and that any documentation, advertising materials, and other
  10.    materials related to such distribution and use acknowledge that the
  11.    software was developed by the University of California, Berkeley, the
  12.    University of Illinois, Urbana, and Sun Microsystems, Inc.  The name of
  13.    either University or Sun Microsystems may not be used to endorse or
  14.    promote products derived from this software without specific prior written
  15.    permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  16.    IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES
  17.    OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
  18.  
  19. #include "sys.h"
  20. #include "indent.h"
  21.  
  22. parser_state *parser_state_tos;
  23.  
  24. #define INITIAL_BUFFER_SIZE 1000
  25. #define INITIAL_STACK_SIZE 2
  26.  
  27. // Function from other file:
  28. extern void diag (int level, char *msg, void *a, void *b);
  29.  
  30. // Functions defined here:
  31. void init_parser (void);
  32. void reset_parser (void);
  33. int inc_pstack (void);
  34. #ifdef DEBUG
  35. void debug_init (void);
  36. #endif
  37. void parse (enum codes tk);
  38. void reduce (void);
  39. INLINE void parse_lparen_in_decl (void);
  40.  
  41.  
  42. void
  43. init_parser ()
  44. {
  45.   parser_state_tos
  46.   = (parser_state *) xmalloc (sizeof (parser_state));
  47.  
  48.   parser_state_tos->p_stack_size = INITIAL_STACK_SIZE;
  49.   parser_state_tos->p_stack
  50.     = (enum codes *) xmalloc (INITIAL_STACK_SIZE * sizeof (enum codes));
  51.   parser_state_tos->il
  52.     = (int *) xmalloc (INITIAL_STACK_SIZE * sizeof (int));
  53.   parser_state_tos->cstk
  54.     = (int *) xmalloc (INITIAL_STACK_SIZE * sizeof (int));
  55.   parser_state_tos->paren_indents = (short *) xmalloc (sizeof (short));
  56.  
  57.   /* Although these are supposed to grow if we reach the end,
  58.      I can find no place in the code which does this. */
  59.   combuf = (char *) xmalloc (INITIAL_BUFFER_SIZE);
  60.   labbuf = (char *) xmalloc (INITIAL_BUFFER_SIZE);
  61.   codebuf = (char *) xmalloc (INITIAL_BUFFER_SIZE);
  62.  
  63.   save_com.size = INITIAL_BUFFER_SIZE;
  64.   save_com.end = save_com.ptr = xmalloc (save_com.size);
  65.  
  66.   di_stack_alloc = 2;
  67.   di_stack = (int *) xmalloc (di_stack_alloc * sizeof (*di_stack));
  68.   
  69.   // Rev kene add some new keywords
  70.   AddSpecialKeys ();
  71.  
  72. }
  73.  
  74. void
  75. reset_parser ()
  76. {
  77.   parser_state_tos->next = 0;
  78.   parser_state_tos->tos = 0;
  79.   parser_state_tos->paren_indents_size = 1;
  80.   parser_state_tos->p_stack[0] = stmt;    /* this is the parser's stack */
  81.   parser_state_tos->last_nl = true;    /* this is true if the last thing
  82.                        scanned was a newline */
  83.   parser_state_tos->last_token = semicolon;
  84.   parser_state_tos->box_com = false;
  85.   parser_state_tos->cast_mask = 0;
  86.   parser_state_tos->noncast_mask = 0;
  87.   parser_state_tos->sizeof_mask = 0;
  88.   parser_state_tos->block_init = false;
  89.   parser_state_tos->block_init_level = 0;
  90.   parser_state_tos->col_1 = false;
  91.   parser_state_tos->com_col = 0;
  92.   parser_state_tos->dec_nest = 0;
  93.   parser_state_tos->i_l_follow = 0;
  94.   parser_state_tos->ind_level = 0;
  95.   parser_state_tos->last_u_d = false;
  96.   parser_state_tos->p_l_follow = 0;
  97.   parser_state_tos->paren_level = 0;
  98.   parser_state_tos->paren_depth = 0;
  99.   parser_state_tos->search_brace = false;
  100.   parser_state_tos->use_ff = false;
  101.   parser_state_tos->its_a_keyword = false;
  102.   parser_state_tos->sizeof_keyword = false;
  103.   parser_state_tos->dumped_decl_indent = false;
  104.   parser_state_tos->in_parameter_declaration = false;
  105.   parser_state_tos->just_saw_decl = false;
  106.   parser_state_tos->in_decl = false;
  107.   parser_state_tos->decl_on_line = false;
  108.   parser_state_tos->in_or_st = false;
  109.   parser_state_tos->bl_line = true;
  110.   parser_state_tos->want_blank = false;
  111.   parser_state_tos->in_stmt = false;
  112.   parser_state_tos->ind_stmt = false;
  113.   parser_state_tos->procname = "\0";
  114.   parser_state_tos->procname_end = "\0";
  115.   parser_state_tos->pcase = false;
  116.   parser_state_tos->dec_nest = 0;
  117.   di_stack[parser_state_tos->dec_nest] = 0;
  118.  
  119.   l_com = combuf + INITIAL_BUFFER_SIZE - 5;
  120.   l_lab = labbuf + INITIAL_BUFFER_SIZE - 5;
  121.   l_code = codebuf + INITIAL_BUFFER_SIZE - 5;
  122.   combuf[0] = codebuf[0] = labbuf[0] = ' ';
  123.   combuf[1] = codebuf[1] = labbuf[1] = '\0';
  124.  
  125.   else_if = 1;
  126.   else_or_endif = false;
  127.   s_lab = e_lab = labbuf + 1;
  128.   s_code = e_code = codebuf + 1;
  129.   s_com = e_com = combuf + 1;
  130.  
  131.   line_no = 1;
  132.   had_eof = false;
  133.   break_comma = false;
  134.   bp_save = 0;
  135.   be_save = 0;
  136.   if (tabsize <= 0)
  137.     tabsize = 1;
  138. }
  139.  
  140. /* like ++parser_state_tos->tos but checks for stack overflow and extends
  141.    stack if necessary.  */
  142.  
  143. int
  144. inc_pstack ()
  145. {
  146.   if (++parser_state_tos->tos >= parser_state_tos->p_stack_size)
  147.     {
  148.       parser_state_tos->p_stack_size *= 2;
  149.       parser_state_tos->p_stack = (enum codes *)
  150.     xrealloc ((char *) parser_state_tos->p_stack,
  151.           parser_state_tos->p_stack_size * sizeof (enum codes), "p_stack");
  152.       parser_state_tos->il = (int *)
  153.     xrealloc ((char *) parser_state_tos->il,
  154.           parser_state_tos->p_stack_size * sizeof (int), "il");
  155.       parser_state_tos->cstk = (int *)
  156.     xrealloc ((char *) parser_state_tos->cstk,
  157.           parser_state_tos->p_stack_size * sizeof (int), "cstk");
  158.     }
  159.   return parser_state_tos->tos;
  160. }
  161.  
  162. #ifdef DEBUG
  163. static char **debug_symbol_strings;
  164.  
  165. void
  166. debug_init ()
  167. {
  168.   int size = ((int) period + 4) * sizeof (char *);
  169.  
  170.   debug_symbol_strings = (char **) xmalloc (size);
  171.  
  172.   debug_symbol_strings[code_eof] = "code_eof";
  173.   debug_symbol_strings[newline] = "newline";
  174.   debug_symbol_strings[lparen] = "lparen";
  175.   debug_symbol_strings[rparen] = "rparen";
  176.   debug_symbol_strings[unary_op] = "unary_op";
  177.   debug_symbol_strings[binary_op] = "binary_op";
  178.   debug_symbol_strings[postop] = "postop";
  179.   debug_symbol_strings[question] = "question";
  180.   debug_symbol_strings[casestmt] = "casestmt";
  181.   debug_symbol_strings[colon] = "colon";
  182.   debug_symbol_strings[semicolon] = "semicolon";
  183.   debug_symbol_strings[lbrace] = "lbrace";
  184.   debug_symbol_strings[rbrace] = "rbrace";
  185.   debug_symbol_strings[ident] = "ident";
  186.   debug_symbol_strings[comma] = "comma";
  187.   debug_symbol_strings[comment] = "comment";
  188.   debug_symbol_strings[swstmt] = "swstmt";
  189.   debug_symbol_strings[preesc] = "preesc";
  190.   debug_symbol_strings[form_feed] = "form_feed";
  191.   debug_symbol_strings[decl] = "decl";
  192.   debug_symbol_strings[sp_paren] = "sp_paren";
  193.   debug_symbol_strings[sp_nparen] = "sp_nparen";
  194.   debug_symbol_strings[ifstmt] = "ifstmt";
  195.   debug_symbol_strings[whilestmt] = "whilestmt";
  196.   debug_symbol_strings[forstmt] = "forstmt";
  197.   debug_symbol_strings[stmt] = "stmt";
  198.   debug_symbol_strings[stmtl] = "stmtl";
  199.   debug_symbol_strings[elselit] = "elselit";
  200.   debug_symbol_strings[dolit] = "dolit";
  201.   debug_symbol_strings[dohead] = "dohead";
  202.   debug_symbol_strings[dostmt] = "dostmt";
  203.   debug_symbol_strings[ifhead] = "ifhead";
  204.   debug_symbol_strings[elsehead] = "elsehead";
  205.   debug_symbol_strings[period] = "period";
  206. }
  207.  
  208. #endif
  209.  
  210. void
  211. parse (enum codes tk) /* the code for the construct scanned */
  212. {
  213.   int i;
  214.  
  215. #ifdef DEBUG
  216.   if (debug)
  217.     {
  218.       if (tk >= code_eof && tk <= period)
  219.     printf ("Parse: %s\n", debug_symbol_strings[tk]);
  220.       else
  221.     printf ("Parse: Unknown code: %d for %s\n",
  222.         (int) tk, token ? token : "NULL");
  223.     }
  224. #endif
  225.  
  226.   while (parser_state_tos->p_stack[parser_state_tos->tos] == ifhead
  227.      && tk != elselit)
  228.     {
  229.       /* true if we have an if without an else */
  230.  
  231.       /* apply the if(..) stmt ::= stmt reduction */
  232.       parser_state_tos->p_stack[parser_state_tos->tos] = stmt;
  233.       reduce ();        /* see if this allows any reduction */
  234.     }
  235.  
  236.  
  237.   switch (tk)
  238.     {                /* go on and figure out what to do with the
  239.                    input */
  240.  
  241.     case decl:            /* scanned a declaration word */
  242.       parser_state_tos->search_brace = btype_2;
  243.       /* indicate that following brace should be on same line */
  244.       if (parser_state_tos->p_stack[parser_state_tos->tos] != decl)
  245.     {            /* only put one declaration onto stack */
  246.       break_comma = true;    /* while in declaration, newline should be
  247.                    forced after comma */
  248.       inc_pstack ();
  249.       parser_state_tos->p_stack[parser_state_tos->tos] = decl;
  250.       parser_state_tos->il[parser_state_tos->tos] = parser_state_tos->i_l_follow;
  251.  
  252.       if (ljust_decl)
  253.         {            /* only do if we want left justified
  254.                    declarations */
  255.           parser_state_tos->ind_level = 0;
  256.           for (i = parser_state_tos->tos - 1; i > 0; --i)
  257.         if (parser_state_tos->p_stack[i] == decl)
  258.           /* indentation is number of declaration levels deep we are
  259.              times spaces per level */
  260.           parser_state_tos->ind_level += ind_size;
  261.           parser_state_tos->i_l_follow = parser_state_tos->ind_level;
  262.         }
  263.     }
  264.       break;
  265.  
  266.     case ifstmt:        /* scanned if (...) */
  267.       if (parser_state_tos->p_stack[parser_state_tos->tos] == elsehead
  268.       && else_if)        /* "else if ..." */
  269.     parser_state_tos->i_l_follow
  270.       = parser_state_tos->il[parser_state_tos->tos];
  271.     case dolit:        /* 'do' */
  272.     case forstmt:        /* for (...) */
  273.       inc_pstack ();
  274.       parser_state_tos->p_stack[parser_state_tos->tos] = tk;
  275.       parser_state_tos->il[parser_state_tos->tos]
  276.     = parser_state_tos->ind_level = parser_state_tos->i_l_follow;
  277.       parser_state_tos->i_l_follow += ind_size;    /* subsequent statements
  278.                            should be indented 1 */
  279.       parser_state_tos->search_brace = btype_2;
  280.       break;
  281.  
  282.     case lbrace:        /* scanned { */
  283.       break_comma = false;    /* don't break comma in an initial list */
  284.       if (parser_state_tos->p_stack[parser_state_tos->tos] == stmt
  285.       || parser_state_tos->p_stack[parser_state_tos->tos] == stmtl)
  286.     /* it is a random, isolated stmt group or a declaration */
  287.     parser_state_tos->i_l_follow += ind_size;
  288.       else if (parser_state_tos->p_stack[parser_state_tos->tos] == decl)
  289.     {
  290.       parser_state_tos->i_l_follow += ind_size;
  291.       if (parser_state_tos->last_rw == rw_struct_like
  292.           && parser_state_tos->block_init_level == 0
  293.           && parser_state_tos->last_token != rparen
  294.           && !btype_2)
  295. #if 0
  296.           && !parser_state_tos->col_1)
  297. #endif
  298.         {
  299.           parser_state_tos->ind_level += brace_indent;
  300.           parser_state_tos->i_l_follow += brace_indent;
  301.         }
  302.     }
  303.       else
  304.     {
  305.       if (s_code == e_code)
  306.         {
  307.           /* only do this if there is nothing on the line */
  308.  
  309.           parser_state_tos->ind_level -= ind_size;
  310.           /* it is a group as part of a while, for, etc. */
  311.  
  312.           /* For -bl formatting, indent by brace_indent additional spaces
  313.              e.g. if (foo == bar) { <--> brace_indent spaces (in this
  314.              example, 4) */
  315.           if (!btype_2)
  316.         {
  317.           parser_state_tos->ind_level += brace_indent;
  318.           parser_state_tos->i_l_follow += brace_indent;
  319.           if (parser_state_tos->p_stack[parser_state_tos->tos]
  320.               == swstmt)
  321.             case_ind += brace_indent;
  322.         }
  323.  
  324.           if (parser_state_tos->p_stack[parser_state_tos->tos] == swstmt
  325.           && case_indent
  326.           >= ind_size)
  327.         parser_state_tos->ind_level -= ind_size;
  328.           /* for a switch, brace should be two levels out from the code */
  329.         }
  330.     }
  331.  
  332.       inc_pstack ();
  333.       parser_state_tos->p_stack[parser_state_tos->tos] = lbrace;
  334.       parser_state_tos->il[parser_state_tos->tos] = parser_state_tos->ind_level;
  335.       inc_pstack ();
  336.       parser_state_tos->p_stack[parser_state_tos->tos] = stmt;
  337.       /* allow null stmt between braces */
  338.       parser_state_tos->il[parser_state_tos->tos] = parser_state_tos->i_l_follow;
  339.       break;
  340.  
  341.     case whilestmt:        /* scanned while (...) */
  342.       if (parser_state_tos->p_stack[parser_state_tos->tos] == dohead)
  343.     {
  344.       /* it is matched with do stmt */
  345.       parser_state_tos->ind_level = parser_state_tos->i_l_follow
  346.         = parser_state_tos->il[parser_state_tos->tos];
  347.       inc_pstack ();
  348.       parser_state_tos->p_stack[parser_state_tos->tos] = whilestmt;
  349.       parser_state_tos->il[parser_state_tos->tos]
  350.         = parser_state_tos->ind_level = parser_state_tos->i_l_follow;
  351.     }
  352.       else
  353.     {            /* it is a while loop */
  354.       inc_pstack ();
  355.       parser_state_tos->p_stack[parser_state_tos->tos] = whilestmt;
  356.       parser_state_tos->il[parser_state_tos->tos] = parser_state_tos->i_l_follow;
  357.       parser_state_tos->i_l_follow += ind_size;
  358.       parser_state_tos->search_brace = btype_2;
  359.     }
  360.  
  361.       break;
  362.  
  363.     case elselit:        /* scanned an else */
  364.  
  365.       if (parser_state_tos->p_stack[parser_state_tos->tos] != ifhead)
  366.     diag (1, "Unmatched 'else'", NULL, NULL);
  367.       else
  368.     {
  369.       /* indentation for else should be same as for if */
  370.       parser_state_tos->ind_level
  371.         = parser_state_tos->il[parser_state_tos->tos];
  372.       /* everything following should be in 1 level */
  373.       parser_state_tos->i_l_follow = (parser_state_tos->ind_level
  374.                       + ind_size);
  375.  
  376.       parser_state_tos->p_stack[parser_state_tos->tos] = elsehead;
  377.       /* remember if with else */
  378.       parser_state_tos->search_brace = btype_2 | else_if;
  379.     }
  380.       break;
  381.  
  382.     case rbrace:        /* scanned a } */
  383.       /* stack should have <lbrace> <stmt> or <lbrace> <stmtl> */
  384.       if (parser_state_tos->p_stack[parser_state_tos->tos - 1] == lbrace)
  385.     {
  386.       parser_state_tos->ind_level = parser_state_tos->i_l_follow
  387.         = parser_state_tos->il[--parser_state_tos->tos];
  388.       parser_state_tos->p_stack[parser_state_tos->tos] = stmt;
  389.     }
  390.       else
  391.     diag (1, "Stmt nesting error.", 0, 0);
  392.       break;
  393.  
  394.     case swstmt:        /* had switch (...) */
  395.       inc_pstack ();
  396.       parser_state_tos->p_stack[parser_state_tos->tos] = swstmt;
  397.       parser_state_tos->cstk[parser_state_tos->tos] = case_ind;
  398.       /* save current case indent level */
  399.       parser_state_tos->il[parser_state_tos->tos] = parser_state_tos->i_l_follow;
  400.       case_ind = parser_state_tos->i_l_follow + case_indent;    /* cases should be one
  401.                                    level down from
  402.                                    switch */
  403.       /* statements should be two levels in */
  404.       parser_state_tos->i_l_follow += case_indent + ind_size;
  405.  
  406.       parser_state_tos->search_brace = btype_2;
  407.       break;
  408.  
  409.     case semicolon:        /* this indicates a simple stmt */
  410.       break_comma = false;    /* turn off flag to break after commas in a
  411.                    declaration */
  412.       if (parser_state_tos->p_stack[parser_state_tos->tos] == dostmt)
  413.     {
  414.       parser_state_tos->p_stack[parser_state_tos->tos] = stmt;
  415.     }
  416.       else
  417.     {
  418.       inc_pstack ();
  419.       parser_state_tos->p_stack[parser_state_tos->tos] = stmt;
  420.       parser_state_tos->il[parser_state_tos->tos]
  421.         = parser_state_tos->ind_level;
  422.     }
  423.       break;
  424.  
  425.     default:            /* this is an error */
  426.       diag (1, "Unknown code to parser", 0, 0);
  427.       return;
  428.  
  429.  
  430.     }                /* end of switch */
  431.  
  432.   reduce ();            /* see if any reduction can be done */
  433.  
  434. #ifdef DEBUG
  435.   if (debug)
  436.     {
  437.       printf ("\nParseStack [%d]:\n", (int) parser_state_tos->p_stack_size);
  438.       for (i = 1; i <= parser_state_tos->tos; ++i)
  439.     printf ("  stack[%d] =>   stack: %d   ind_level: %d\n",
  440.         (int) i, (int) parser_state_tos->p_stack[i],
  441.         (int) parser_state_tos->il[i]);
  442.       printf ("\n");
  443.     }
  444. #endif
  445.  
  446.   return;
  447. }
  448.  
  449. /* NAME: reduce
  450.  
  451. FUNCTION: Implements the reduce part of the parsing algorithm
  452.  
  453. ALGORITHM: The following reductions are done.  Reductions are repeated until
  454.    no more are possible.
  455.  
  456. Old TOS             New TOS <stmt> <stmt>         <stmtl> <stmtl> <stmt>
  457.    <stmtl> do <stmt>             dohead <dohead> <whilestmt>
  458.    <dostmt> if <stmt>             "ifstmt" switch <stmt>         <stmt>
  459.    decl <stmt>             <stmt> "ifelse" <stmt>         <stmt> for
  460.    <stmt>             <stmt> while <stmt>             <stmt>
  461.    "dostmt" while         <stmt>
  462.  
  463. On each reduction, parser_state_tos->i_l_follow (the indentation for the
  464.    following line) is set to the indentation level associated with the old
  465.    TOS.
  466.  
  467. PARAMETERS: None
  468.  
  469. RETURNS: Nothing
  470.  
  471. GLOBALS: parser_state_tos->cstk parser_state_tos->i_l_follow =
  472.    parser_state_tos->il parser_state_tos->p_stack = parser_state_tos->tos =
  473.  
  474. CALLS: None
  475.  
  476. CALLED BY: parse
  477.  
  478. HISTORY: initial coding     November 1976    D A Willcox of CAC
  479.  
  480. */
  481. /*----------------------------------------------*\
  482. |   REDUCTION PHASE                    |
  483. \*----------------------------------------------*/
  484. void reduce ()
  485. {
  486.  
  487.   register int i;
  488.  
  489.   for (;;)
  490.     {                /* keep looping until there is nothing left
  491.                    to reduce */
  492.  
  493.       switch (parser_state_tos->p_stack[parser_state_tos->tos])
  494.     {
  495.  
  496.     case stmt:
  497.       switch (parser_state_tos->p_stack[parser_state_tos->tos - 1])
  498.         {
  499.  
  500.         case stmt:
  501.         case stmtl:
  502.           /* stmtl stmt or stmt stmt */
  503.           parser_state_tos->p_stack[--parser_state_tos->tos] = stmtl;
  504.           break;
  505.  
  506.         case dolit:    /* <do> <stmt> */
  507.           parser_state_tos->p_stack[--parser_state_tos->tos] = dohead;
  508.           parser_state_tos->i_l_follow
  509.         = parser_state_tos->il[parser_state_tos->tos];
  510.           break;
  511.  
  512.         case ifstmt:
  513.           /* <if> <stmt> */
  514.           parser_state_tos->p_stack[--parser_state_tos->tos] = ifhead;
  515.           for (i = parser_state_tos->tos - 1;
  516.            (parser_state_tos->p_stack[i] != stmt
  517.             && parser_state_tos->p_stack[i] != stmtl
  518.             && parser_state_tos->p_stack[i] != lbrace);
  519.            --i);
  520.           parser_state_tos->i_l_follow = parser_state_tos->il[i];
  521.           /* for the time being, we will assume that there is no else on
  522.              this if, and set the indentation level accordingly. If an
  523.              else is scanned, it will be fixed up later */
  524.           break;
  525.  
  526.         case swstmt:
  527.           /* <switch> <stmt> */
  528.           case_ind = parser_state_tos->cstk[parser_state_tos->tos - 1];
  529.  
  530.         case decl:        /* finish of a declaration */
  531.         case elsehead:
  532.           /* <<if> <stmt> else> <stmt> */
  533.         case forstmt:
  534.           /* <for> <stmt> */
  535.         case whilestmt:
  536.           /* <while> <stmt> */
  537.           parser_state_tos->p_stack[--parser_state_tos->tos] = stmt;
  538.           parser_state_tos->i_l_follow = parser_state_tos->il[parser_state_tos->tos];
  539.           break;
  540.  
  541.         default:        /* <anything else> <stmt> */
  542.           return;
  543.  
  544.         }            /* end of section for <stmt> on top of stack */
  545.       break;
  546.  
  547.     case whilestmt:    /* while (...) on top */
  548.       if (parser_state_tos->p_stack[parser_state_tos->tos - 1] == dohead)
  549.         {
  550.           /* it is termination of a do while */
  551. #if 0
  552.           parser_state_tos->p_stack[--parser_state_tos->tos] = stmt;
  553. #endif
  554.           parser_state_tos->p_stack[--parser_state_tos->tos] = dostmt;
  555.           break;
  556.         }
  557.       else
  558.         return;
  559.  
  560.     default:        /* anything else on top */
  561.       return;
  562.  
  563.     }
  564.     }
  565. }
  566.  
  567. /* This kludge is called from main.  It is just like parse(semicolon) except
  568.    that it does not clear break_comma.  Leaving break_comma alone is
  569.    necessary to make sure that "int foo(), bar()" gets formatted correctly
  570.    under -bc.  */
  571.  
  572. INLINE void
  573. parse_lparen_in_decl ()
  574. {
  575.   inc_pstack ();
  576.   parser_state_tos->p_stack[parser_state_tos->tos] = stmt;
  577.   parser_state_tos->il[parser_state_tos->tos] = parser_state_tos->ind_level;
  578.  
  579.   reduce ();
  580. }
  581.